package com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.EmployeeDao;
import com.dao.KaoqinDao;
import com.pojo.Employee;
import com.pojo.Kaoqin;

@Service("KaoqinService")
public class KaoqinServiceImpl implements KaoqinService {

	@Autowired
	private KaoqinDao kaoqinDao;
	@Autowired
	private EmployeeDao employeeDao;
	@Override
	public boolean addKaoqin(Kaoqin kaoqin) {
		// TODO Auto-generated method stub
		boolean result=false;
		if(kaoqin.getKaoqin_Id()==null) {
			if(kaoqinDao.addKaoqinNotId(kaoqin)>0)
				result=true;
		}else
			if(kaoqinDao.addKaoqin(kaoqin)>0)
				result=true;
		return result;
	}

	@Override
	public boolean deletKaoqinForId(Integer kaoqin_id) {
		// TODO Auto-generated method stub
		boolean result=false;
		if(kaoqinDao.deleteKaoqinForId(kaoqin_id)>0)
			result=true;
		return result;
	}

	@Override
	public Kaoqin GetKaoqin(Integer kaoqin_id) {
		// TODO Auto-generated method stub
		return kaoqinDao.selectKaoqinForId(kaoqin_id);
	}

	@Override
	public List<Kaoqin> GetAllKaoqin() {
		// TODO Auto-generated method stub
		return kaoqinDao.selectAllKaoqin();
	}

	@Override
	public boolean updateKaoqin(Kaoqin kaoqin) {
		// TODO Auto-generated method stub
		boolean result=false;
		if(kaoqinDao.deleteKaoqinForId(kaoqin.getKaoqin_Id())>0&&kaoqinDao.addKaoqin(kaoqin)>0)
			result=true;
		return result;
	}

	@Override
	public Employee GetEmployee(Integer employee_id) {
		// TODO Auto-generated method stub
		return employeeDao.selectEmployeeForId(employee_id);
	}

	@Override
	public List<Kaoqin> allByEmployee(Integer eid) {
		// TODO Auto-generated method stub
		return kaoqinDao.selectAllKaoqinForEmployee(eid);
	}

	@Override
	public List<Kaoqin> allByType(String type) {
		// TODO Auto-generated method stub
		return kaoqinDao.selectAllKaoqinForType(type);
	}

}
